# extracts MAC address from ifconfig program
# and put its value in MAC env variable
ifconfig -l | find -p MAC | nset -v -l 1 -cs 16 -cf 32 MAC
if %lasterror% ne 0 then
	color red
	echo "GetMAC.nsh - ERRO!"
	echo "GetMAC.nsh - Nao foi possivel obter o MAC Address da placa."
	echo "GetMAC.nsh - Network Stack esta habilitado no setup da BIOS?"
	color
	set -d MAC
	pause -q
	exit 1
else
	# generates a MAC without dashes
	echo %MAC% | nset -v -l 1 -cs 1 -cf 2 MAC1
	echo %MAC% | nset -v -l 1 -cs 4 -cf 5 MAC2
	echo %MAC% | nset -v -l 1 -cs 7 -cf 8 MAC3
	echo %MAC% | nset -v -l 1 -cs 10 -cf 11 MAC4
	echo %MAC% | nset -v -l 1 -cs 13 -cf 14 MAC5
	echo %MAC% | nset -v -l 1 -cs 16 -cf 17 MAC6
	set -v MAC %MAC1%%MAC2%%MAC3%%MAC4%%MAC5%%MAC6%
	set -d MAC1
	set -d MAC2
	set -d MAC3
	set -d MAC4
	set -d MAC5
	set -d MAC6
	echo "GetMAC.nsh - MAC Address eh: %MAC%"
endif